# !/bin/bash

apt-get update
apt-get install aptitude -y
aptitude update
aptitude install libglib2.0-dev subversion yasm nasm -y
svn checkout http://galactus.googlecode.com/svn/trunk/ galactus
rm -rf galactus/gtm

wget http://www.ffmpeg.org/releases/ffmpeg-1.2.tar.gz
tar -vzxf ffmpeg-1.2.tar.gz
cd ffmpeg-1.2
./configure
make
make install
cd ..
rm -rf ffmpeg-1.2
rm ffmpeg-1.2.tar.gz

file_contents='
# Port on which the server is listening. You must select a different\n
# port from your standard HTTP web server if it is running on the same\n
# computer.\n
Port 8090\n

# bind to all IPs aliased or not\n
BindAddress 0.0.0.0\n

# Number of simultaneous HTTP connections that can be handled. It has\n
# to be defined *before* the MaxClients parameter, since it defines the\n
# MaxClients maximum limit.\n
MaxHTTPConnections 2000\n

# max number of simultaneous clients\n
MaxClients 1000\n

# max bandwidth per-client (kb/s)\n
MaxBandwidth 1000\n

# Suppress that if you want to launch ffserver as a daemon.\n
NoDaemon\n

<Feed feed1.ffm>\n
	File /tmp/feed1.ffm\n
	FileMaxSize 50M\n
</Feed>\n

<Stream camera.mjpeg>\n
	Feed feed1.ffm\n
	Format mpjpeg\n
	VideoFrameRate 15\n
	VideoBitRate 128\n
	VideoBufferSize 40000\n
	VideoQMin 1\n
	VideoQMax 5\n
	VideoSize 640x480\n
	VideoIntraOnly\n
	NoAudio\n
	Strict -1\n
</Stream>\n
'
echo -e $file_contents > /etc/ffserver.conf

